<template>
  <div id="videoStar">
    <van-loading size="24px"
                 vertical
                 type="spinner"
                 v-if="loading_01">拼命加载中...</van-loading>
    <van-list v-model="loading"
              :finished="finished"
              finished-text="我是有底线的～"
              @load="onLoad"
              :immediate-check="false">
      <!-- <van-pull-refresh v-model="refreshing"
                        @refresh="onRefresh"> -->
      <a href="##">
        <div class="box"
             v-for="(item, index) in table_data01"
             :key="'table' + index">
          <!-- 视频ban -->
          <div class="boxleft">
            <a href=""
               class="aa"><img :src="item.thumPic"></a>
            <a href=""><img src="@/assets/two/play.png"
                   class="play"></a>
          </div>
          <!-- 文字介绍 -->
          <div class="boxright">
            <p class="tit">{{ item.title }}</p>
            <!-- 数字 -->
            <div class="num">
              <div class="one">
                <p>{{ format_num(item.favoriteCount) }}</p>
                <span>点赞数</span>
              </div>
              <div class="two">
                <p>{{ format_num(item.commentCount) }}</p>
                <span>评论数</span>
              </div>
              <div class="three">
                <p>{{ format_num(item.shareCount) }}</p>
                <span>关注数</span>
              </div>
            </div>
            <!-- 作者+时间 -->
            <div class="time">
              <div class="author">
                <a href="">
                  <img :src="item.logo"
                       alt="">
                </a>
                <span>{{ item.nickName }}</span>
              </div>
              <div class="day">发布时间：{{
                    item.releaseTime
                  }}</div>
            </div>
          </div>
        </div>
      </a>
      <!-- </van-pull-refresh> -->
    </van-list>
    <div v-if="table_data01.length == 0 && show">
      <img class="img"
           src="../../../assets/three/Collection.png"
           alt="" />
      <p class="Collection">您尚未收藏任何视频</p>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import { Toast } from 'vant'
Vue.use(Toast)
export default {
  name: 'videoStar',
  components: {},
  data() {
    return {
      page: 1,
      pageSize: 20,
      table_data01: [],
      //  //触底
      loading: false,
      finished: false,
      refreshing: false,
      show: false,
      loading_01: false,
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {
    this.get_data()
  },
  methods: {
    get_data() {
      this.loading = true
      this.loading_01 = true
      this.$axios
        .get('/api/collection/GetAwemeCollection', {
          //   传递参数  text
          params: {
            pageIndex: this.page,
            pageSize: this.pageSize,
          },
        })
        //   请求成功
        .then((res) => {
          if (res.data.code == 0) {
            this.table_data01 = this.table_data01.concat(res.data.data)
            this.loading = false
            this.refreshing = false
            this.show = true
            this.loading_01 = false
            if (res.data.data.length < this.pageSize) {
              this.finished = true
            }
          } else if (res.data.code == 1002) {
            this.loading = false
            this.show = true
            this.loading_01 = false
          }
        })
        .catch((err) => {
          console.log(err)
        })
    },
    // 触底 (滑到底部时)
    onLoad() {
      this.loading = true
      if (this.page * this.pageSize > this.table_data01.length) {
        if (this.table_data01.length == 0) {
          this.loading = false
          this.finished = false
        } else {
          this.loading = false
          this.finished = true
        }
      } else if (this.table_data01.length > 0) {
        this.page = this.page + 1;
        this.get_data()
      }
    },
    //     上拉刷新
    onRefresh() {
      // 清空列表数据
      this.pageIndex = 1
      this.table_data01 = []
      this.get_data()
    },
  },
}
</script>
<style scoped lang="less">
#videoStar {
  width: 92%;
  margin: 0 auto;
  background: #f1f1f1;
  min-height: 100vh;
  a {
    text-decoration: none;
  }
  .box {
    display: flex;
    border: 1px solid transparent;
    border-radius: 8px;
    background: #fff;
    margin-top: 0.2rem;
    // 视频ban
    .boxleft {
      width: 28.98%;
      position: relative;
      > .aa {
        width: 80%;
        height: 2.666667rem;
        display: block;
        margin: 0.266667rem auto 0 auto;
        border-radius: 0.213rem;
        overflow: hidden;
        > img {
          width: 100%;
          height: 100%;
          display: inline-block;
        }
      }
      .play {
        position: absolute;
        top: 32%;
        left: 30%;
      }
    }
    // 文字介绍
    .boxright {
      width: 71.02%;
      .tit {
        width: 84.48%;
        line-height: 0.373333rem;
        font-size: 0.373333rem;
        padding: 0.48rem 0 0.4rem 0.026rem;
        color: #222;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .num {
        display: flex;
        .one > p,
        .two > p,
        .three > p {
          font-family: Dinpro-medium;
          font-weight: 600;
        }
        .one,
        .two {
          width: 34.28%;
        }
        .three {
          width: 30.6%;
        }
        p {
          font-size: 0.293rem;
          text-align: left;
          padding-bottom: 0.186rem;
          color: #222;
        }
        span {
          display: block;
          font-size: 0.266667rem;
          text-align: left;
          padding-bottom: 0.293333rem;
          color: #888;
        }
      }
      .time {
        display: flex;
        height: 0.506667rem;
        padding-bottom: 0.373333rem;
        .author {
          display: flex;
          width: 2.8rem;
          height: 0.506667rem;
          font-size: 0.306rem;
          color: #222;
          a {
            display: block;
            width: 0.506667rem;
            height: 0.506667rem;
            border-radius: 50%;
            overflow: hidden;
            img {
              width: 100%;
              height: 100%;
              display: inline-block;
            }
          }
          > span {
            display: block;
            width: 2.13rem;
            padding-left: 0.133rem;
            padding-top: 0.026667rem;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
        }
        .day {
          margin-left: 0.16rem;
          width: 55.1%;
          line-height: 0.506667rem;
          font-size: 0.306rem;
          color: #888;
          overflow: hidden;
        }
      }
    }
  }
  .nodata {
    width: 100%;
    div {
      width: 8.8rem;
      margin: 3.813rem auto 0 auto;
      img {
        width: 100%;
      }
    }
    p {
      width: 100%;
      text-align: center;
      line-height: 1.733333rem;
      font-size: 0.373rem;
      font-weight: normal;
      font-stretch: normal;
      letter-spacing: 1px;
      color: #888888;
    }
  }
}
.img {
  width: 9.2rem;
  height: 8.933333rem;
  margin: 0 auto;
  display: block;
}
.Collection {
  font-size: 0.373333rem;
  line-height: 0.4rem;
  color: #888888;
  text-align: center;
}
</style>
